<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 声明一个构造函数
        function Person(userName,type,operation) {
            this.userName = userName;
            this.type = type;
            this.operation = operation;
        }
        //利用构造函数创建对象
        var operation1 = function () {
            console.log('近战');
        }
        var obj = new Person('廉颇','力量型',operation1);
        console.log(obj.userName);
        obj.operation();

        // 创建对象二
        var operation2 = function () {
            console.log('远程');
        }
        var obj2 = new Person('后羿','射手型',operation2);
        console.log(obj2.userName);
        obj2.operation();

        // 遍历对象中的属性
        for (var key in obj2) {
            // k 作为变量输出，得到是属性名
            console.log(key);
            //得到是属性值
            console.log(obj2[key]);

        }

        var temp = null;
        console.log(typeof temp);
    </script>
</head>
<body>
    
</body>
</html>